import request from "@/request/request";
import requestMock from "@/request/requestMock";
// 获取三级列表
export const reqCategoryList = () => {
    return request({
        url: "/product/getBaseCategoryList",
        method: "get",
    });
};

// 获取轮播图和楼层数据
export const reqBanners = () => {
    return requestMock({
        url: "/banner",
        method: "get",
    });
};
export const reqFloors = () => {
    return requestMock({
        url: "/floor",
        method: "get",
    });
};

// 获取搜索商品数据
export const reqSearchInfo = searchParams => {
    return request({
        url: `/list`,
        method: "post",
        data: searchParams,
    });
};

// 获取商品详情数据
export const reqGoodsDetailInfo = skuId => {
    return request({
        url: `/item/${skuId}`,
        method: "get",
    });
};

// 获取添加购物车数据和修改购物车数据
export const reqAddOrUpdateShopCart = (skuId, skuNum) => {
    return request({
        url: `/cart/addToCart/${skuId}/${skuNum}`,
        method: "post",
    });
};

// 获取购物车列表数据
export const reqShopCartList = () => {
    return request({
        url: `/cart/cartList`,
        method: "get",
    });
};

// 获取购物车选中状态
export const reqCheckCart = (skuId, isChecked) => {
    return request({
        url: `/cart/checkCart/${skuId}/${isChecked}`,
        method: "get",
    });
};

// 获取购物车全选状态
export const reqCheckAllCart = (isCheckedAll, skuIdList) => {
    return request({
        url: `/cart/batchCheckCart/${isCheckedAll}`,
        method: "post",
        data: skuIdList,
    });
};

// 删除单个购物车数据
export const reqDeleteCart = skuId => {
    return request({
        url: `/cart/deleteCart/${skuId}`,
        method: "delete",
    });
};

// 删除选中商品
export const reqDeleteCheckedCart = skuIdList => {
    return request({
        url: `/cart/batchDeleteCart`,
        method: "delete",
        data: skuIdList,
    });
};

// 获取注册验证码
export const reqRegisterCode = phone => {
    return request({
        url: `/user/passport/sendCode/${phone}`,
        method: "get",
    });
};

// 注册用户
export const reqRegisterUser = userInfo => {
    return request({
        url: `/user/passport/register`,
        method: "post",
        data: userInfo,
    });
};

// 登录用户
export const reqLoginUser = userInfo => {
    return request({
        url: `/user/passport/login`,
        method: "post",
        data: userInfo,
    });
};

// 获取用户信息
export const reqUserInfo = () => {
    return request({
        url: `/user/passport/auth/getUserInfo`,
        method: "get",
    });
};

// 退出登录
export const reqLogout = () => {
    return request({
        url: `/user/passport/logout`,
        method: "get",
    });
};

// 获取订单页地址列表
export const reqAddressInfo = () => {
    return requestMock({
        url: `/user/userAddress/auth/findUserAddressList`,
        method: "get",
    });
};

// 获取订单页交易信息
export const reqTradeInfo = () => {
    return request({
        url: `/order/auth/trade`,
        method: "get",
    });
};

// 提交订单
export const reqSubmitOrder = (tradeNo, tradeInfo) => {
    return request({
        url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
        method: "post",
        data: tradeInfo,
    });
};

// 获取支付信息
export const reqPayInfo = orderId => {
    return request({
        url: `/payment/weixin/createNative/${orderId}`,
        method: "get",
    });
};

// 获取订单支付状态
export const reqPayStatus = orderId => {
    return request({
        url: `/payment/weixin/queryPayStatus/${orderId}`,
        method: "get",
    });
};

// 获取订单列表
export const reqOrderList = (page = 1, limit = 5) => {
    return request({
        url: `/order/auth/${page}/${limit}`,
        method: "get",
    });
};

// 获取订单详情(待做)
export const reqOrderDetail = orderId => {
    return request({
        url: `/order/auth/${orderId}`,
        method: "get",
    });
};
